#include "Blocks/PaintBucketBlock.h"
#include "Blocks/EmptyBucketBlock.h"

namespace PocketSurvival
{
    int32_t PaintBucketBlock::getIndex()
    {
        return Index();
    }
    const std::string &PaintBucketBlock::getBlockName()
    {
        static std::string blockName = "PaintBucketBlock";
        return blockName;
    }

    void PaintBucketBlock::getCreativeValues(std::vector<int32_t> &blockVec)
    {
        for(int32_t index = 0; index < 16; ++index)
        {
            blockVec.push_back(Terrain::MakeBlockValue(getIndex(), 0, SetColor(0, index)));
        }
    }

    int32_t PaintBucketBlock::getDamageDestructionValue(int32_t value)
    {
        return Terrain::MakeBlockValue(EmptyBucketBlock::Index());
    }

    int32_t CombineColors(int32_t color1, int32_t color2)
    {
        Byte4Data colorData;
        colorData.buff[0] = (color1 & 1) + (color2 & 1);
        colorData.buff[1] = ((color1 >> 1) & 1) + ((color2 >> 1) & 1);
        colorData.buff[2] = ((color1 >> 2) & 1) + ((color2 >> 2) & 1);
        colorData.buff[3] = ((color1 >> 3) & 1) + ((color2 >> 3) & 1);
        if(colorData.buff[3] <= 1)
        {
            return colorData.buff[0] | (colorData.buff[1] << 1) | (colorData.buff[2] << 2) | (colorData.buff[3] << 3);
        }
        return 15;
    }


} // namespace PocketSurvival
